angular.module('Controller')
.controller('QgyFinanceAuditModalCtrl',($scope,urls,$localStorage,NgTableParams,commonUtil,cryptUtil,wfAlert,commonConstant,$http, $uibModalInstance, items)->
    $scope.type=type=items.type
    $scope.data=items.data
    $scope.modalTitle=if type!='view' then '财务审核' else '财务明细'
    $scope.modalEnableList=commonConstant.enabledList()
    $scope.check={
        checkStatus:true
        checkResult:undefined
    }
    $scope.checkStatusList=[
        {value:true,name:'是'}
        {value:false,name:'否'}
    ]
    $scope.appointmentDealStatusList=[
        {value:2, name:'待看房'}
        {value:3, name:'已取消'}
        {value:4, name:'已看房'}
    ]
    $scope.appointmentSuccessContractList=[
        {value:true,name:'是'}
        {value:false,name:'否'}
    ]
    editData=()->
#        ##test
#        wfAlert.toastInfo($scope.modalTitle+'成功')
#        $uibModalInstance.close('done')
#        return
#        ##test
        check=$scope.check
        if check.checkStatus==false and !check.checkResult
            wfAlert.toastError('拒绝必须填写拒绝原因')
            return
        reqData={
            checkStatus:check.checkStatus
            reject:check.checkResult
        }
        $http.put("/offLease/#{$scope.data.id}/examine",reqData)
        .success((resp)->
            if resp.code==0
                wfAlert.toastInfo($scope.modalTitle+'成功')
                $uibModalInstance.close('done')
            else
                wfAlert.toastError(resp.message)
        )
    $scope.confirm = ()->
        if type=='view'
            $uibModalInstance.dismiss('cancel')
        else
            editData()
    $scope.cancel =()->
        $uibModalInstance.dismiss('cancel')
)